package com.wuyou.mid;

import java.util.ArrayList;
import java.util.List;

/**
 * 1604. 警告一小时内使用相同员工卡大于等于三次的人
 */
public class AlertNames {

    public static void main(String[] args) {
        String[] keyName = {"daniel", "daniel", "daniel", "luis", "luis", "luis", "luis"};
        String[] keyTime = {"10:00", "10:40", "11:00", "09:00", "11:00", "13:00", "15:00"};
        System.out.println(solution_1(keyName, keyTime));
    }

    public static List<String> solution_1(String[] keyName, String[] keyTime) {
        List<String> res = new ArrayList<>();
        if (keyName.length < 3) return res;
        String lastName = "";
        int tempCount = 1, index = 0, hour = 0, minute = 0;
        for (String name : keyName) {
            if (lastName.equals(name)) {
                int hourTemp = Integer.parseInt(keyTime[index].substring(0, 2));
                int minuteTemp = Integer.parseInt(keyTime[index].substring(3, keyTime[index].length()));
                if (hourTemp - hour == 0 || (hourTemp - hour == 1 && minuteTemp - minute <= 0)) {
                    tempCount++;
                } else {
                    tempCount = 1;
                }
            } else {
                tempCount = 1;
                lastName = name;
                hour = Integer.parseInt(keyTime[index].substring(0, 2));
                minute = Integer.parseInt(keyTime[index].substring(3, keyTime[index].length()));
            }
            index++;
        }
        return res;
    }
}
